package models

import (
	"time"
	"user_srv/basic/config"
)

type Reservation struct {
	Id                uint      `gorm:"column:id;type:bigint(20) UNSIGNED;primaryKey;not null;" json:"id"`
	PatientId         uint      `gorm:"column:patient_id;type:bigint(20);not null;" json:"patient_id"`
	DoctorId          uint      `gorm:"column:doctor_id;type:bigint(20);not null;" json:"doctor_id"`
	ReservationStatus uint      `gorm:"column:reservation_status;type:tinyint(1);comment: 预约状态：1：未通过，2：通过;not null;" json:"reservation_status"` //  预约状态：1：未通过，2：通过
	CreateAt          time.Time `gorm:"column:create_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"create_at"`
	UpdatedAt         time.Time `gorm:"column:updated_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"updated_at"`
}

func (r *Reservation) TableName() string {
	return "reservation"
}
func (r *Reservation) UpdateStatus() error { //修改状态
	return config.DB.Model(&Reservation{}).Where("id = ?", r.Id).Update("reservation_status", r.ReservationStatus).Error
}
